package org.apache.jmeter.gui.rcp.tree;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

import org.apache.jmeter.gui.rcp.RcpGUIFactory;
import org.apache.jmeter.util.JMeterUtils;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.PlatformUI;

public class JMeterViewLabelProvider extends LabelProvider {

	public String getText(Object obj) {
		return obj.toString();
	}
	public Image getImage(Object obj) {
		String imageKey = ((JMeterTreeNode)obj).getImageName();
		String imageName = RcpGUIFactory.getIcon(imageKey, true);

		InputStream is = JMeterUtils.class.getClassLoader().getResourceAsStream(imageName);
		
		return new Image(PlatformUI.getWorkbench().getDisplay(), is);
	}
}
